package com.swm.util;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.swm.mapper.StockJsonDataMapper;
import com.swm.pojo.Stock_Day_Data;
import com.swm.pojo.Stock_Json_Data;
import org.apache.ibatis.session.SqlSession;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

import static com.swm.util.ConditionUtilDB.getMaxPrice;

/**
 * @author 师文明
 * @data 2024/12/23 下午3:11
 **/
public class getStockDayData5071 {

    //0-20
    public static double sumz020;
    public static double sumf020;
    public static double sum020;
    public static int num0020;
    public static int numu020;
    public static int numd020;
    public static int ban020 = 0;
    //20-50
    public static double sumz2050;
    public static double sumf2050;
    public static double sum2050;
    public static double sum32050;
    public static double sum52050;
    public static double sum102050;
    public static double sum202050;
    public static int num02050;
    public static int numu2050;
    public static int numd2050;
    public static int numu32050;
    public static int numd32050;
    public static int numu52050;
    public static int numd52050;
    public static int numu102050;
    public static int numd102050;
    public static int numu202050;
    public static int numd202050;
    public static int ban2050 = 0;
    //50-100
    public static double sumz50100;
    public static double sumf50100;
    public static double sum50100;
    public static double sum350100;
    public static double sum550100;
    public static double sum1050100;
    public static double sum2050100;
    public static int num050100;
    public static int numu50100;
    public static int numd50100;
    public static int numu350100;
    public static int numd350100;
    public static int numu550100;
    public static int numd550100;
    public static int numu1050100;
    public static int numd1050100;
    public static int numu2050100;
    public static int numd2050100;
    public static int ban50100 = 0;
    //100-200
    public static double sumz100200;
    public static double sumf100200;
    public static double sum100200;
    public static double sum3100200;
    public static double sum5100200;
    public static double sum10100200;
    public static double sum20100200;
    public static int num0100200;
    public static int numu100200;
    public static int numd100200;
    public static int numu3100200;
    public static int numd3100200;
    public static int numu5100200;
    public static int numd5100200;
    public static int numu10100200;
    public static int numd10100200;
    public static int numu20100200;
    public static int numd20100200;
    public static int ban100200 = 0;
    //200-370
    public static double sumz200370;
    public static double sumf200370;
    public static double sum200370;
    public static double sum3200370;
    public static double sum5200370;
    public static double sum10200370;
    public static double sum20200370;
    public static int num0200370;
    public static int numu200370;
    public static int numd200370;
    public static int numu3200370;
    public static int numd3200370;
    public static int numu5200370;
    public static int numd5200370;
    public static int numu10200370;
    public static int numd10200370;
    public static int numu20200370;
    public static int numd20200370;
    public static int ban200370 = 0;
    public static DecimalFormat df = new DecimalFormat("#0.000");
    static SqlSession sqlSession = SqlSessionUtil.openSession();
    static StockJsonDataMapper stockJsonDataMapper = sqlSession.getMapper(StockJsonDataMapper.class);
    private static ArrayList<String> dateList020 = new ArrayList<String>();
    private static ArrayList<String> dateList2050 = new ArrayList<String>();
    private static ArrayList<String> dateList50100 = new ArrayList<String>();
    private static ArrayList<String> dateList100200 = new ArrayList<String>();
    private static ArrayList<String> dateList200370 = new ArrayList<String>();
    private static ArrayList<String> datalist =   new ArrayList<String>();

    public static void main(String[] args) throws Exception {
        List<Stock_Json_Data> stockJsonDatalist = stockJsonDataMapper.selectStockJsonData();
        System.out.println(stockJsonDatalist.size());
        if (!stockJsonDatalist.isEmpty()) {
            for (int i = 0; i < stockJsonDatalist.size(); i++) {
                Stock_Json_Data stockJsonData = stockJsonDatalist.get(i);
                try {
                    getData(stockJsonData);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
            //Thread.sleep(200000);
            double v020 = 0;
            double vz020 = 0;
            double vf020 = 0;
            System.out.println("120天内低位蛟龙出海");
            System.out.println("------------------------");
            if (num0020 != 0 && sum020 != 0) {
                v020 = sum020 / num0020;
                vz020 = sumz020 / numu020;
                vf020 = sumf020 / numd020;
            }
            System.out.println("0-20");
            System.out.println(("一天后涨的次数：" + numu020 + "  跌的次数：" + numd020 + "  上涨概率： " + df.format((double) numu020 * 100 / num0020)) + "%  平均涨跌幅：" + df.format(v020) + "%  平均涨幅：" + df.format(vz020) + "%  平均跌幅：" + df.format(vf020));
            System.out.println("板数：" + ban020);
            System.out.println("中股天数：" + dateList020.size());


            double v2050 = 0;
            double vz2050 = 0;
            double vf2050 = 0;
            double v32050 = 0;
            double v52050 = 0;
            double v102050 = 0;
            double v202050 = 0;

            if (num02050 != 0 && sum2050 != 0) {
                v2050 = sum2050 / num02050;
                vz2050 = sumz2050 / numu2050;
                vf2050 = sumf2050 / numd2050;
            }
            if (num02050 != 0 && sum32050 != 0) {
                v32050 = sum32050 / num02050;
            }
            if (num02050 != 0 && sum52050 != 0) {
                v52050 = sum52050 / num02050;
            }
            if (num02050 != 0 && sum102050 != 0) {
                v102050 = sum102050 / num02050;
            }
            if (num02050 != 0 && sum202050 != 0) {
                v202050 = sum202050 / num02050;
            }

            System.out.println("----------");
            System.out.println("20-50");
            System.out.println(("一天后涨的次数：" + numu2050 + "  跌的次数：" + numd2050 + "  上涨概率： " + df.format((double) numu2050 * 100 / num02050)) + "%  平均涨跌幅：" + df.format(v2050) + "%  平均涨幅：" + df.format(vz2050) + "%  平均跌幅：" + df.format(vf2050));
            System.out.println(("3天后涨的次数：" + numu32050 + "  跌的次数：" + numd32050 + "  上涨概率： " + df.format((double) numu32050 * 100 / num02050)) + "%  平均涨幅：" + df.format(v32050));
            System.out.println(("5天后涨的次数：" + numu52050 + "  跌的次数：" + numd52050 + "  上涨概率： " + df.format((double) numu52050 * 100 / num02050)) + "%  平均涨幅：" + df.format(v52050));
            System.out.println(("10天后涨的次数：" + numu102050 + "  跌的次数：" + numd102050 + "  上涨概率： " + df.format((double) numu102050 * 100 / num02050)) + "%  平均涨幅：" + df.format(v102050));
            System.out.println(("20天后涨的次数：" + numu202050 + "  跌的次数：" + numd202050 + "  上涨概率： " + df.format((double) numu202050 * 100 / num02050)) + "%  平均涨幅：" + df.format(v202050));
            System.out.println("板数：" + ban2050);
            System.out.println("中股天数：" + dateList2050.size());


            double v50100 = 0;
            double vz50100 = 0;
            double vf50100 = 0;
            double v350100 = 0;
            double v550100 = 0;
            double v1050100 = 0;
            double v2050100 = 0;

            if (num050100 != 0 && sum50100 != 0) {
                v50100 = sum50100 / num050100;
                vz50100 = sumz50100 / numu50100;
                vf50100 = sumf50100 / numd50100;
            }
            if (num050100 != 0 && sum350100 != 0) {
                v350100 = sum350100 / num050100;
            }
            if (num050100 != 0 && sum550100 != 0) {
                v550100 = sum550100 / num050100;
            }
            if (num050100 != 0 && sum1050100 != 0) {
                v1050100 = sum1050100 / num050100;
            }
            if (num050100 != 0 && sum2050100 != 0) {
                v2050100 = sum2050100 / num050100;
            }

            System.out.println("----------");
            System.out.println("50-100");
            System.out.println(("一天后涨的次数：" + numu50100 + "  跌的次数：" + numd50100 + "  上涨概率： " + df.format((double) numu50100 * 100 / num050100)) + "%  平均涨跌幅：" + df.format(v50100) + "%  平均涨幅：" + df.format(vz50100) + "%  平均跌幅：" + df.format(vf50100));
            System.out.println(("3天后涨的次数：" + numu350100 + "  跌的次数：" + numd350100 + "  上涨概率： " + df.format((double) numu350100 * 100 / num050100)) + "%  平均涨幅：" + df.format(v350100));
            System.out.println(("5天后涨的次数：" + numu550100 + "  跌的次数：" + numd550100 + "  上涨概率： " + df.format((double) numu550100 * 100 / num050100)) + "%  平均涨幅：" + df.format(v550100));
            System.out.println(("10天后涨的次数：" + numu1050100 + "  跌的次数：" + numd1050100 + "  上涨概率： " + df.format((double) numu1050100 * 100 / num050100)) + "%  平均涨幅：" + df.format(v1050100));
            System.out.println(("20天后涨的次数：" + numu2050100 + "  跌的次数：" + numd2050100 + "  上涨概率： " + df.format((double) numu2050100 * 100 / num050100)) + "%  平均涨幅：" + df.format(v2050100));
            System.out.println("板数：" + ban50100);
            System.out.println("中股天数：" + dateList50100.size());

            double v100200 = 0;
            double vz100200 = 0;
            double vf100200 = 0;
            double v3100200 = 0;
            double v5100200 = 0;
            double v10100200 = 0;
            double v20100200 = 0;

            if (num0100200 != 0 && sum100200 != 0) {
                v100200 = sum100200 / num0100200;
                vz100200 = sumz100200 / numu100200;
                vf100200 = sumf100200 / numd100200;
            }
            if (num0100200 != 0 && sum3100200 != 0) {
                v3100200 = sum3100200 / num0100200;
            }
            if (num0100200 != 0 && sum5100200 != 0) {
                v5100200 = sum5100200 / num0100200;
            }
            if (num0100200 != 0 && sum10100200 != 0) {
                v10100200 = sum10100200 / num0100200;
            }
            if (num0100200 != 0 && sum20100200 != 0) {
                v20100200 = sum20100200 / num0100200;
            }

            System.out.println("----------");
            System.out.println("100-200");
            System.out.println(("一天后涨的次数：" + numu100200 + "  跌的次数：" + numd100200 + "  上涨概率： " + df.format((double) numu100200 * 100 / num0100200)) + "%  平均涨跌幅：" + df.format(v100200) + "%  平均涨幅：" + df.format(vz100200) + "%  平均跌幅：" + df.format(vf100200));
            System.out.println(("3天后涨的次数：" + numu3100200 + "  跌的次数：" + numd3100200 + "  上涨概率： " + df.format((double) numu3100200 * 100 / num0100200)) + "%  平均涨幅：" + df.format(v3100200));
            System.out.println(("5天后涨的次数：" + numu5100200 + "  跌的次数：" + numd5100200 + "  上涨概率： " + df.format((double) numu5100200 * 100 / num0100200)) + "%  平均涨幅：" + df.format(v5100200));
            System.out.println(("10天后涨的次数：" + numu10100200 + "  跌的次数：" + numd10100200 + "  上涨概率： " + df.format((double) numu10100200 * 100 / num0100200)) + "%  平均涨幅：" + df.format(v10100200));
            System.out.println(("20天后涨的次数：" + numu20100200 + "  跌的次数：" + numd20100200 + "  上涨概率： " + df.format((double) numu20100200 * 100 / num0100200)) + "%  平均涨幅：" + df.format(v20100200));
            System.out.println("板数：" + ban100200);
            System.out.println("中股天数：" + dateList100200.size());

            double v200370 = 0;
            double vz200370 = 0;
            double vf200370 = 0;
            double v3200370 = 0;
            double v5200370 = 0;
            double v10200370 = 0;
            double v20200370 = 0;

            if (num0200370 != 0 && sum200370 != 0) {
                v200370 = sum200370 / num0200370;
                vz200370 = sumz200370 / numu200370;
                vf200370 = sumf200370 / numd200370;
            }
            if (num0200370 != 0 && sum3200370 != 0) {
                v3200370 = sum3200370 / num0200370;
            }
            if (num0200370 != 0 && sum5200370 != 0) {
                v5200370 = sum5200370 / num0200370;
            }
            if (num0200370 != 0 && sum10200370 != 0) {
                v10200370 = sum10200370 / num0200370;
            }
            if (num0200370 != 0 && sum20200370 != 0) {
                v20200370 = sum20200370 / num0200370;
            }

            System.out.println("----------");
            System.out.println("200-370");
            System.out.println(("一天后涨的次数：" + numu200370 + "  跌的次数：" + numd200370 + "  上涨概率： " + df.format((double) numu200370 * 100 / num0200370)) + "%  平均涨跌幅：" + df.format(v200370) + "%  平均涨幅：" + df.format(vz200370) + "%  平均跌幅：" + df.format(vf200370));
            System.out.println(("3天后涨的次数：" + numu3200370 + "  跌的次数：" + numd3200370 + "  上涨概率： " + df.format((double) numu3200370 * 100 / num0200370)) + "%  平均涨幅：" + df.format(v3200370));
            System.out.println(("5天后涨的次数：" + numu5200370 + "  跌的次数：" + numd5200370 + "  上涨概率： " + df.format((double) numu5200370 * 100 / num0200370)) + "%  平均涨幅：" + df.format(v5200370));
            System.out.println(("10天后涨的次数：" + numu10200370 + "  跌的次数：" + numd10200370 + "  上涨概率： " + df.format((double) numu10200370 * 100 / num0200370)) + "%  平均涨幅：" + df.format(v10200370));
            System.out.println(("20天后涨的次数：" + numu20200370 + "  跌的次数：" + numd20200370 + "  上涨概率： " + df.format((double) numu20200370 * 100 / num0200370)) + "%  平均涨幅：" + df.format(v20200370));
            System.out.println("板数：" + ban200370);
            System.out.println("中股天数：" + dateList200370.size());
        }
    }

    public static void getData(Stock_Json_Data stockJsonData) throws Exception {
        String jsondata = stockJsonData.getJsondata();
        JSONObject jsonObject = JSONObject.parseObject(jsondata);

        String o = jsonObject.get(stockJsonData.getName()).toString();
        List<Stock_Day_Data> stockDayData = JSONArray.parseArray(o, Stock_Day_Data.class);
      /*  if(stockDayData.size() >  0){
            String getdate = stockDayData.get(0).getGetdate();
            if(!getdate.equals("2025-04-25")){
                return;
            }
        }*/

        if (stockDayData.size() > 170) {

            for (int i = 1; i < 21; i++) {
                //今日成交额
                double m0 = stockDayData.get(i).getMoney();
                //今日收盘价
                double s = stockDayData.get(i).getS();
                //昨日成交额
                double m1 = stockDayData.get(i + 1).getMoney();
                double m4 = m0 / m1;
                //昨日涨幅
                double v = stockDayData.get(i).getZdf();

                for (int j = 5; j < 31; j++) {
                    boolean priceAmplitude = ConditionUtilDB.getPriceAmplitude(stockDayData, i, j);
                    boolean priceredu = getPriceredu(stockDayData, i + j, 120, 10);
                    JSONObject lines = getLines(stockDayData, i);
                    double f1 = Double.parseDouble(lines.get("f1").toString());
                    boolean b = false;
                    if (j < 11) {
                        JSONObject lines10 = getLines(stockDayData, i + 10);
                        double f10 = Double.parseDouble(lines10.get("f1").toString());
                        b = f1 > f10;
                    } else if (j > 10 && j < 21) {
                        JSONObject lines10 = getLines(stockDayData, i + 10);
                        double f10 = Double.parseDouble(lines10.get("f1").toString());
                        JSONObject lines20 = getLines(stockDayData, i + 20);
                        double f20 = Double.parseDouble(lines20.get("f1").toString());
                        b = f1 > f10 && f10 > f20;
                    } else if (j > 20) {
                        JSONObject lines10 = getLines(stockDayData, i + 10);
                        double f10 = Double.parseDouble(lines10.get("f1").toString());
                        JSONObject lines20 = getLines(stockDayData, i + 20);
                        double f20 = Double.parseDouble(lines20.get("f1").toString());
                        JSONObject lines30 = getLines(stockDayData, i + 30);
                        double f30 = Double.parseDouble(lines30.get("f1").toString());
                        b = f1 > f10 && f10 > f20 && f20 > f30;
                    }
                    double maxPrice = getMaxPrice(stockDayData, i, j);
                    boolean contains = datalist.contains(stockDayData.get(i).getName() + stockDayData.get(i).getGetdate());
                    if (priceAmplitude && b && priceredu && m4 > 2 && s > maxPrice&&!contains) {
                        //次日涨幅
                        double v11 = stockDayData.get(i - 1).getZdf();
                        if (v11 > 0 || v11 == 0) {
                            numu020++;
                            sumz020 += v11;
                        } else {
                            sumf020 += v11;
                            numd020++;
                        }
                        sum020 += v11;
                        num0020++;
                        if (!dateList020.contains(stockDayData.get(i).getGetdate())) {
                            dateList020.add(stockDayData.get(i).getGetdate());
                        }
                        if (v11 > 9.8) {
                            ban020++;
                        }
                        datalist.add(stockDayData.get(i).getName()+stockDayData.get(i).getGetdate());
                        System.out.println(stockDayData.get(i).getName() + " : " + j + "天 " + stockDayData.get(i).getGetdate() + "  当日涨幅" + v + "   次日涨幅" + v11);
                    }
                }


            }
        }

        if (stockDayData.size() > 200) {
            for (int i = 21; i < 50; i++) {
                //昨日涨幅
                double v = stockDayData.get(i).getZdf();

                //收盘价
                double s = stockDayData.get(i).getS();  //收盘价

                //今日成交额
                double m0 = stockDayData.get(i).getMoney();
                //昨日成交额
                double m1 = stockDayData.get(i + 1).getMoney();
                double m4 = m0 / m1;
                for (int j = 5; j < 31; j++) {
                    boolean priceAmplitude = ConditionUtilDB.getPriceAmplitude(stockDayData, i, j);
                    boolean priceredu = getPriceredu(stockDayData, i + j, 120, 10);
                    JSONObject lines = getLines(stockDayData, i);
                    double f1 = Double.parseDouble(lines.get("f1").toString());
                    boolean b = false;
                    if (j < 11) {
                        JSONObject lines10 = getLines(stockDayData, i + 10);
                        double f10 = Double.parseDouble(lines10.get("f1").toString());
                        b = f1 > f10;
                    } else if (j > 10 && j < 21) {
                        JSONObject lines10 = getLines(stockDayData, i + 10);
                        double f10 = Double.parseDouble(lines10.get("f1").toString());
                        JSONObject lines20 = getLines(stockDayData, i + 20);
                        double f20 = Double.parseDouble(lines20.get("f1").toString());
                        b = f1 > f10 && f10 > f20;
                    } else if (j > 20 && j < 31) {
                        JSONObject lines10 = getLines(stockDayData, i + 10);
                        double f10 = Double.parseDouble(lines10.get("f1").toString());
                        JSONObject lines20 = getLines(stockDayData, i + 20);
                        double f20 = Double.parseDouble(lines20.get("f1").toString());
                        JSONObject lines30 = getLines(stockDayData, i + 30);
                        double f30 = Double.parseDouble(lines30.get("f1").toString());
                        b = f1 > f10 && f10 > f20 && f20 > f30;
                    }
                    double maxPrice = getMaxPrice(stockDayData, i, j);
                    boolean contains = datalist.contains(stockDayData.get(i).getName() + stockDayData.get(i).getGetdate());
                    if (priceAmplitude && b && priceredu && m4 > 2 && s > maxPrice&&!contains) {
                        //第3天收盘价
                        double s03 = stockDayData.get(i - 3).getS();
                        double v3 = (s03 - s) * 100 / s;
                        //第5天收盘价
                        double s05 = stockDayData.get(i - 5).getS();
                        double v5 = (s05 - s) * 100 / s;
                        //第10天收盘价
                        double s010 = stockDayData.get(i - 10).getS();
                        double v10 = (s010 - s) * 100 / s;
                        //第20天收盘价
                        double s020 = stockDayData.get(i - 20).getS();
                        double v20 = (s020 - s) * 100 / s;
                        //次日涨幅
                        double v11 = stockDayData.get(i - 1).getZdf();

                        if (v11 > 0 || v11 == 0) {
                            numu2050++;
                            sumz2050 += v11;
                        } else {
                            sumf2050 += v11;
                            numd2050++;
                        }
                        sum2050 += v11;
                        sum32050 += v3;
                        sum52050 += v5;
                        sum102050 += v10;
                        sum202050 += v20;

                        num02050++;

                        if (s03 > s) {
                            numu32050++;
                        } else {
                            numd32050++;
                        }

                        if (s05 > s) {
                            numu52050++;
                        } else {
                            numd52050++;
                        }

                        if (s010 > s) {
                            numu102050++;
                        } else {
                            numd102050++;
                        }

                        if (s020 > s) {
                            numu202050++;
                        } else {
                            numd202050++;
                        }
                      /*  String date = stockDayData.get(i).getGetdate();
                        if(date.startsWith("2023")){
                            System.out.println(date);
                        }*/
                        if (!dateList2050.contains(stockDayData.get(i).getGetdate())) {
                            dateList2050.add(stockDayData.get(i).getGetdate());
                        }
                        if (v11 > 9.8) {
                            ban2050++;
                        }
                        datalist.add(stockDayData.get(i).getName()+stockDayData.get(i).getGetdate());
                        System.out.println(stockDayData.get(i).getName() + " : " + j + "天 " + stockDayData.get(i).getGetdate() + "  当日涨幅" + v + "   次日涨幅" + v11 + "   3日涨幅" + df.format(v3) + "   5日涨幅" + df.format(v5) + "   10日涨幅" + df.format(v10) + "   20日涨幅" + df.format(v20));
                    }
                }

            }
        }

        if (stockDayData.size() > 250) {
            for (int i = 50; i < 100; i++) {
                //昨日涨幅
                double v = stockDayData.get(i).getZdf();

                //收盘价
                double s = stockDayData.get(i).getS();  //收盘价

                //今日成交额
                double m0 = stockDayData.get(i).getMoney();
                //昨日成交额
                double m1 = stockDayData.get(i + 1).getMoney();
                double m4 = m0 / m1;
                for (int j = 5; j < 31; j++) {
                    boolean priceAmplitude = ConditionUtilDB.getPriceAmplitude(stockDayData, i, j);
                    boolean priceredu = getPriceredu(stockDayData, i + j, 120, 10);
                    JSONObject lines = getLines(stockDayData, i);
                    double f1 = Double.parseDouble(lines.get("f1").toString());
                    boolean b = false;
                    if (j < 11) {
                        JSONObject lines10 = getLines(stockDayData, i + 10);
                        double f10 = Double.parseDouble(lines10.get("f1").toString());
                        b = f1 > f10;
                    } else if (j > 10 && j < 21) {
                        JSONObject lines10 = getLines(stockDayData, i + 10);
                        double f10 = Double.parseDouble(lines10.get("f1").toString());
                        JSONObject lines20 = getLines(stockDayData, i + 20);
                        double f20 = Double.parseDouble(lines20.get("f1").toString());
                        b = f1 > f10 && f10 > f20;
                    } else if (j > 20 && j < 31) {
                        JSONObject lines10 = getLines(stockDayData, i + 10);
                        double f10 = Double.parseDouble(lines10.get("f1").toString());
                        JSONObject lines20 = getLines(stockDayData, i + 20);
                        double f20 = Double.parseDouble(lines20.get("f1").toString());
                        JSONObject lines30 = getLines(stockDayData, i + 30);
                        double f30 = Double.parseDouble(lines30.get("f1").toString());
                        b = f1 > f10 && f10 > f20 && f20 > f30;
                    }
                    double maxPrice = getMaxPrice(stockDayData, i, j);
                    boolean contains = datalist.contains(stockDayData.get(i).getName() + stockDayData.get(i).getGetdate());
                    if (priceAmplitude && b && priceredu && m4 > 2 && s > maxPrice&&!contains) {
                        //第3天收盘价
                        double s03 = stockDayData.get(i - 3).getS();
                        double v3 = (s03 - s) * 100 / s;
                        //第5天收盘价
                        double s05 = stockDayData.get(i - 5).getS();
                        double v5 = (s05 - s) * 100 / s;
                        //第10天收盘价
                        double s010 = stockDayData.get(i - 10).getS();
                        double v10 = (s010 - s) * 100 / s;
                        //第20天收盘价
                        double s020 = stockDayData.get(i - 20).getS();
                        double v20 = (s020 - s) * 100 / s;

                        //次日涨幅
                        double v11 = stockDayData.get(i - 1).getZdf();


                        if (v11 > 0 || v11 == 0) {
                            numu50100++;
                            sumz50100 += v11;
                        } else {
                            sumf50100 += v11;
                            numd50100++;
                        }
                        sum50100 += v11;
                        sum350100 += v3;
                        sum550100 += v5;
                        sum1050100 += v10;
                        sum2050100 += v20;

                        num050100++;

                        if (s03 > s) {
                            numu350100++;
                        } else {
                            numd350100++;
                        }

                        if (s05 > s) {
                            numu550100++;
                        } else {
                            numd550100++;
                        }

                        if (s010 > s) {
                            numu1050100++;
                        } else {
                            numd1050100++;
                        }

                        if (s020 > s) {
                            numu2050100++;
                        } else {
                            numd2050100++;
                        }
                      /*  String date = stockDayData.get(i).getGetdate();
                        if(date.startsWith("2023")){
                            System.out.println(date);
                        }*/
                        if (!dateList50100.contains(stockDayData.get(i).getGetdate())) {
                            dateList50100.add(stockDayData.get(i).getGetdate());
                        }
                        if (v11 > 9.8) {
                            ban50100++;
                        }
                        datalist.add(stockDayData.get(i).getName()+stockDayData.get(i).getGetdate());
                        System.out.println(stockDayData.get(i).getName() + " : "  + j + "天 "+ stockDayData.get(i).getGetdate() + "  当日涨幅" + v + "   次日涨幅" + v11 + "   3日涨幅" + df.format(v3) + "   5日涨幅" + df.format(v5) + "   10日涨幅" + df.format(v10) + "   20日涨幅" + df.format(v20));
                    }
                }
            }
        }

        if (stockDayData.size() > 350) {
            for (int i = 100; i < 200; i++) {
                //昨日涨幅
                double v = stockDayData.get(i).getZdf();

                //收盘价
                double s = stockDayData.get(i).getS();  //收盘价

                //今日成交额
                double m0 = stockDayData.get(i).getMoney();
                //昨日成交额
                double m1 = stockDayData.get(i + 1).getMoney();
                double m4 = m0 / m1;
                for (int j = 5; j < 31; j++) {
                    boolean priceAmplitude = ConditionUtilDB.getPriceAmplitude(stockDayData, i, j);
                    boolean priceredu = getPriceredu(stockDayData, i + j, 120, 10);
                    JSONObject lines = getLines(stockDayData, i);
                    double f1 = Double.parseDouble(lines.get("f1").toString());
                    boolean b = false;
                    if (j < 11) {
                        JSONObject lines10 = getLines(stockDayData, i + 10);
                        double f10 = Double.parseDouble(lines10.get("f1").toString());
                        b = f1 > f10;
                    } else if (j > 10 && j < 21) {
                        JSONObject lines10 = getLines(stockDayData, i + 10);
                        double f10 = Double.parseDouble(lines10.get("f1").toString());
                        JSONObject lines20 = getLines(stockDayData, i + 20);
                        double f20 = Double.parseDouble(lines20.get("f1").toString());
                        b = f1 > f10 && f10 > f20;
                    } else if (j > 20 && j < 31) {
                        JSONObject lines10 = getLines(stockDayData, i + 10);
                        double f10 = Double.parseDouble(lines10.get("f1").toString());
                        JSONObject lines20 = getLines(stockDayData, i + 20);
                        double f20 = Double.parseDouble(lines20.get("f1").toString());
                        JSONObject lines30 = getLines(stockDayData, i + 30);
                        double f30 = Double.parseDouble(lines30.get("f1").toString());
                        b = f1 > f10 && f10 > f20 && f20 > f30;
                    }
                    double maxPrice = getMaxPrice(stockDayData, i, j);
                    boolean contains = datalist.contains(stockDayData.get(i).getName() + stockDayData.get(i).getGetdate());
                    if (priceAmplitude && b && priceredu && m4 > 2 && s > maxPrice&&!contains) {
                        double s03 = stockDayData.get(i - 3).getS();
                        double v3 = (s03 - s) * 100 / s;
                        //第5天收盘价
                        double s05 = stockDayData.get(i - 5).getS();
                        double v5 = (s05 - s) * 100 / s;
                        //第10天收盘价
                        double s010 = stockDayData.get(i - 10).getS();
                        double v10 = (s010 - s) * 100 / s;
                        //第20天收盘价
                        double s020 = stockDayData.get(i - 20).getS();
                        double v20 = (s020 - s) * 100 / s;

                        //次日涨幅
                        double v11 = stockDayData.get(i - 1).getZdf();

                        if (v11 > 0 || v11 == 0) {
                            numu100200++;
                            sumz50100 += v11;
                        } else {
                            sumf100200 += v11;
                            numd100200++;
                        }
                        sum100200 += v11;
                        sum3100200 += v3;
                        sum5100200 += v5;
                        sum10100200 += v10;
                        sum20100200 += v20;

                        num0100200++;

                        if (s03 > s) {
                            numu3100200++;
                        } else {
                            numd3100200++;
                        }

                        if (s05 > s) {
                            numu5100200++;
                        } else {
                            numd5100200++;
                        }

                        if (s010 > s) {
                            numu10100200++;
                        } else {
                            numd10100200++;
                        }

                        if (s020 > s) {
                            numu20100200++;
                        } else {
                            numd20100200++;
                        }
                      /*  String date = stockDayData.get(i).getGetdate();
                        if(date.startsWith("2023")){
                            System.out.println(date);
                        }*/
                        if (!dateList100200.contains(stockDayData.get(i).getGetdate())) {
                            dateList100200.add(stockDayData.get(i).getGetdate());
                        }
                        if (v11 > 9.8) {
                            ban2050++;
                        }
                        datalist.add(stockDayData.get(i).getName()+stockDayData.get(i).getGetdate());
                        System.out.println(stockDayData.get(i).getName() + " : " + j + "天 "+ stockDayData.get(i).getGetdate() + "  当日涨幅" + v + "   次日涨幅" + v11 + "   3日涨幅" + df.format(v3) + "   5日涨幅" + df.format(v5) + "   10日涨幅" + df.format(v10) + "   20日涨幅" + df.format(v20));
                    }
                }
            }
        }

        if (stockDayData.size() > 490) {
            for (int i = 200; i < 340; i++) {
                //昨日涨幅
                double v = stockDayData.get(i).getZdf();

                //收盘价
                double s = stockDayData.get(i).getS();  //收盘价

                //今日成交额
                double m0 = stockDayData.get(i).getMoney();
                //昨日成交额
                double m1 = stockDayData.get(i + 1).getMoney();
                double m4 = m0 / m1;
                for (int j = 5; j < 31; j++) {
                    boolean priceAmplitude = ConditionUtilDB.getPriceAmplitude(stockDayData, i, j);
                    boolean priceredu = getPriceredu(stockDayData, i + j, 120, 10);
                    JSONObject lines = getLines(stockDayData, i);
                    double f1 = Double.parseDouble(lines.get("f1").toString());
                    boolean b = false;
                    if (j < 11) {
                        JSONObject lines10 = getLines(stockDayData, i + 10);
                        double f10 = Double.parseDouble(lines10.get("f1").toString());
                        b = f1 > f10;
                    } else if (j > 10 && j < 21) {
                        JSONObject lines10 = getLines(stockDayData, i + 10);
                        double f10 = Double.parseDouble(lines10.get("f1").toString());
                        JSONObject lines20 = getLines(stockDayData, i + 20);
                        double f20 = Double.parseDouble(lines20.get("f1").toString());
                        b = f1 > f10 && f10 > f20;
                    } else if (j > 20 && j < 31) {
                        JSONObject lines10 = getLines(stockDayData, i + 10);
                        double f10 = Double.parseDouble(lines10.get("f1").toString());
                        JSONObject lines20 = getLines(stockDayData, i + 20);
                        double f20 = Double.parseDouble(lines20.get("f1").toString());
                        JSONObject lines30 = getLines(stockDayData, i + 30);
                        double f30 = Double.parseDouble(lines30.get("f1").toString());
                        b = f1 > f10 && f10 > f20 && f20 > f30;
                    }
                    double maxPrice = getMaxPrice(stockDayData, i, j);
                    boolean contains = datalist.contains(stockDayData.get(i).getName() + stockDayData.get(i).getGetdate());
                    if (priceAmplitude && b && priceredu && m4 > 2 && s > maxPrice&&!contains) {
                        double s03 = stockDayData.get(i - 3).getS();
                        double v3 = (s03 - s) * 100 / s;
                        //第5天收盘价
                        double s05 = stockDayData.get(i - 5).getS();
                        double v5 = (s05 - s) * 100 / s;
                        //第10天收盘价
                        double s010 = stockDayData.get(i - 10).getS();
                        double v10 = (s010 - s) * 100 / s;
                        //第20天收盘价
                        double s020 = stockDayData.get(i - 20).getS();
                        double v20 = (s020 - s) * 100 / s;

                        //次日涨幅
                        double v11 = stockDayData.get(i - 1).getZdf();

                        if (v11 > 0 || v11 == 0) {
                            numu200370++;
                            sumz200370 += v11;
                        } else {
                            sumf200370 += v11;
                            numd200370++;
                        }
                        sum200370 += v11;
                        sum3200370 += v3;
                        sum5200370 += v5;
                        sum10200370 += v10;
                        sum20200370 += v20;

                        num0200370++;

                        if (s03 > s) {
                            numu3200370++;
                        } else {
                            numd3200370++;
                        }

                        if (s05 > s) {
                            numu5200370++;
                        } else {
                            numd5200370++;
                        }

                        if (s010 > s) {
                            numu10200370++;
                        } else {
                            numd10200370++;
                        }

                        if (s020 > s) {
                            numu20200370++;
                        } else {
                            numd20200370++;
                        }
                      /*  String date = stockDayData.get(i).getGetdate();
                        if(date.startsWith("2023")){
                            System.out.println(date);
                        }*/
                        if (!dateList200370.contains(stockDayData.get(i).getGetdate())) {
                            dateList200370.add(stockDayData.get(i).getGetdate());
                        }
                        if (v11 > 9.8) {
                            ban200370++;
                        }
                        datalist.add(stockDayData.get(i).getName()+stockDayData.get(i).getGetdate());
                        System.out.println(stockDayData.get(i).getName() + " : "+ j + "天 " + stockDayData.get(i).getGetdate() + "  当日涨幅" + v + "   次日涨幅" + v11 + "   3日涨幅" + df.format(v3) + "   5日涨幅" + df.format(v5) + "   10日涨幅" + df.format(v10) + "   20日涨幅" + df.format(v20));
                    }
                }
            }
        }
    }

    //获取所有均线
    public static JSONObject getLines(List<Stock_Day_Data> stockDayData, int startDay) {
        //日线
        double totalsix1 = 0.0;
        double totalth1 = 0.0;
        double totaltw1 = 0.0;
        double totalte1 = 0.0;
        double totalf1 = 0.0;
        for (int j = 0; j < 60; j++) {
            double price = stockDayData.get(startDay + j).getS();

            if (j < 5) {
                totalf1 += price;
            }
            if (j < 10) {
                totalte1 += price;
            }
            if (j < 20) {
                totaltw1 += price;

            }
            if (j < 30) {
                totalth1 += price;

            }
            totalsix1 += price;

        }
        double six1 = totalsix1 / 60;
        double th1 = totalth1 / 30;
        double tw1 = totaltw1 / 20;
        double te1 = totalte1 / 10;
        double f1 = totalf1 / 5;
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("f1", f1);
        jsonObject.put("te1", te1);
        jsonObject.put("tw1", tw1);
        jsonObject.put("th1", th1);
        jsonObject.put("six1", six1);
        return jsonObject;

    }

    //近120天 价格处于低位
    public static boolean getPrice(List<Stock_Day_Data> stockDayData, int startDay) {
        //最近120天内收盘价集合
        List<Double> prices = new ArrayList<>();
        double s1 = stockDayData.get(startDay + 1).getS();
        double s2 = stockDayData.get(startDay).getS();
        for (int j = 0; j < 10; j++) {
            //收盘价
            double p2 = stockDayData.get(startDay + j).getS();
            prices.add(p2);
        }
        // 使用List的sort()方法和Lambda表达式进行排序
        prices.sort(Double::compare);
        return s2 < prices.get(2)/*s1==prices.get(0)*/;
    }

    //近120天 价格处于低位
    public static boolean getPriceincre(List<Stock_Day_Data> stockDayData, int startDay, int high, int low) {
        //最近120天内收盘价集合
        List<Double> prices = new ArrayList<>();
        double s1 = stockDayData.get(startDay + 1).getS();
        double s2 = stockDayData.get(startDay).getS();
        for (int j = 0; j < high; j++) {
            //收盘价
            double p2 = stockDayData.get(startDay + j).getS();
            prices.add(p2);
        }
        // 使用List的sort()方法和Lambda表达式进行排序
        prices.sort(Double::compare);
        return s2 > prices.get(low)/*s1==prices.get(0)*/;
    }

    //近120天 价格处于低位
    public static boolean getPriceredu(List<Stock_Day_Data> stockDayData, int startDay, int high, int low) {
        //最近120天内收盘价集合
        List<Double> prices = new ArrayList<>();
        double s1 = stockDayData.get(startDay + 1).getS();
        double s2 = stockDayData.get(startDay).getS();
        for (int j = 0; j < high; j++) {
            //收盘价
            double p2 = stockDayData.get(startDay + j).getS();
            prices.add(p2);
        }
        // 使用List的sort()方法和Lambda表达式进行排序
        prices.sort(Double::compare);
        return s2 < prices.get(low)/*s1==prices.get(0)*/;
    }

    //近120天 价格处于低位
    public static boolean getPrice12010(List<Stock_Day_Data> stockDayData, int startDay) {
        //最近120天内收盘价集合
        List<Double> prices = new ArrayList<>();
        double s2 = stockDayData.get(startDay).getS();
        for (int j = 0; j < 120; j++) {
            //收盘价
            double p2 = stockDayData.get(startDay + j).getS();
            prices.add(p2);
        }
        // 使用List的sort()方法和Lambda表达式进行排序
        prices.sort(Double::compare);
        return s2 < prices.get(20)/*s1==prices.get(0)*/;
    }

    //近120天 价格处于低位
    public static boolean getPrice2010(List<Stock_Day_Data> stockDayData, int startDay) {
        //最近120天内收盘价集合
        List<Double> prices = new ArrayList<>();
        double s1 = stockDayData.get(startDay + 1).getS();
        double s2 = stockDayData.get(startDay).getS();
        for (int j = 0; j < 20; j++) {
            //收盘价
            double p2 = stockDayData.get(startDay + j).getS();
            prices.add(p2);
        }
        // 使用List的sort()方法和Lambda表达式进行排序
        prices.sort(Double::compare);
        return s2 > prices.get(10)/*s1==prices.get(0)*/;
    }

    //近120天 价格处于低位
    public static boolean getPrice8010(List<Stock_Day_Data> stockDayData, int startDay) {
        //最近120天内收盘价集合
        List<Double> prices = new ArrayList<>();
        double s1 = stockDayData.get(startDay + 1).getS();
        double s2 = stockDayData.get(startDay).getS();
        for (int j = 0; j < 80; j++) {
            //收盘价
            double p2 = stockDayData.get(startDay + j).getS();
            prices.add(p2);
        }
        // 使用List的sort()方法和Lambda表达式进行排序
        prices.sort(Double::compare);
        return s2 < prices.get(10)/*s1==prices.get(0)*/;
    }
}

